#include "stdafx.h"
#include "InstanceTouch.h"
#include <sstream>
#include "FriendDef.h"

DECL_INSTANCE_TOUCH(ETouch_Friend);

struct  FriendDefReflectionRegister
{
	FriendDefReflectionRegister()
	{
		REGISTER_REFLECTION_MEMBER(FriendDef,m_iID,INVALID_ID).Editor_SetAsPrimaryKey();
		REGISTER_REFLECTION_MEMBER(FriendDef,m_sDisplayName,std::string("DefaultDisplayName")).Editor_SetAsDisplayName();
		REGISTER_REFLECTION_MEMBER(FriendDef,m_bIsActive,true).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(FriendDef,m_nMaxSendGiftCount,uint32(3)).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(FriendDef,m_nMaxTakeGiftCount,uint32(2)).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(FriendDef,m_nMaxDelFriendCount,uint32(1)).Editor_SetAsRaw();
		REGISTER_REFLECTION_MEMBER(FriendDef,m_nMaxSendApplyCount,uint32(30)).Editor_SetAsRaw();


		REGISTER_REFLECTION_MEMBER(FriendLvlCountDef,m_iID,INVALID_ID).Editor_SetAsPrimaryKey();
		REGISTER_REFLECTION_MEMBER(FriendLvlCountDef,m_iFriendCount,uint32(2)).Editor_SetAsRaw();


		GlobalClassManager::Instance().RegisterClass(FriendDef::s_GetReflection(),eDefaultDef_Friend);
		GlobalDefManager::Instance().RegisterDefManger(&FriendDefManager::Instance());

		GlobalClassManager::Instance().RegisterClass(FriendLvlCountDef::s_GetReflection(),eDefaultDef_FriendLvlCount);
		GlobalDefManager::Instance().RegisterDefManger(&FriendLvlCountDefManager::Instance());
		
	}
}___frienddefreflectionregister;

rewrite void FriendDefManager::OnArchieveReaded()
{
	m_pFriendDef=NULL;
	__FriendDefManager::OnArchieveReaded();
	std::vector<const FriendDef *> vFriendDefs;
	Enumerate(vFriendDefs);
	for(uint32 ii=0;ii<vFriendDefs.size();ii++)
	{
		const FriendDef * pDef=vFriendDefs[ii];
		if(pDef->m_bIsActive)
		{
			m_pFriendDef=pDef;
			break;
		}
	}
	if(m_pFriendDef==NULL)
	{
		printf("FriendDefManager::OnArchieveReaded,No active Friend def");
		m_pFriendDef=&DefaultStaticItem();
	}

}